<template>
	<view class="container">
		<carHeader style="padding:10rpx;"
		  :title="'订单详情'"></carHeader>
		
		<view class="info">
			<view class="one">
				<view>
					<text  space="nbsp">核销码 {{ orderList[0].ordVerificationCode }}</text>
				</view>
				<view>
					<text class="content">车辆：{{ orderList[0].type }}/{{ orderList[0].carNum }}</text>
				</view>
			</view>
			
			<view class="one" >
				<view>
					<text >服务内容 </text>
				</view>
				<view>
					<text class="content" >
						{{ orderList[0].proName}}
					</text>
					<text class="detail">
					 ￥{{ orderList[0].newPrice}}
					 </text>
				</view>
			</view>
			
			<view class="one" style="border-bottom: none;">
				<view>
					<text >订单信息</text>
				</view>
				
				<view>
					<text class="content" >
						原价
					</text>
					<text class="detail">￥{{ orderList[0].newPrice}}</text>
				</view>
				
				<view>
					<text class="content" >
						优惠
					</text>
					<text class="detail" >￥{{ orderList[0].couPreferentialMoney}}</text>
				</view>
				
				<view>
					<text class="content" >
						实付金额
					</text>
					<text class="detail" >￥{{ orderList[0].ordActualPrice}}</text>
				</view>
				
				<view>
					<text class="content" >
						订单编号
					</text>
					<text class="detail" >{{ orderList[0].ordNumber}}</text>
				</view>
				
				<view>
					<text class="content" >
						预约时间
					</text>
					<text class="detail" >{{ orderList[0].bookingTime}}</text>
				</view>
				
				<view>
					<text class="content" >
						支付时间
					</text>
					<text class="detail" >{{ orderList[0].payTime}}</text>
				</view>
				
				<view>
					<text class="content" >
						核销时间
					</text>
					<text class="detail" >{{ orderList[0].verificationTime}}</text>
				</view>
				
			</view>
		</view>
		
		
		<view class="btn">
			<u-button @click="dialogToggle()"
			:disabled="isVerified"
			type="primary" 
			:color="isVerified ? '#808080' : '#0662E6'"
			shape="circle" 
			>
			{{isVerified ? '已核销' : '确认核销'}}</u-button>
			<!-- <view v-else>已核销</view> -->
		</view>
		 
		
		
		<view>
		<!-- 提示窗示例 -->
			<uni-popup ref="alertDialog" type="dialog">
				<uni-popup-dialog 
				
				cancelText="取消" 
				confirmText="确认" 
				title="核销此订单" 
				content="请您仔细核对订单,此操作不可撤销请谨慎操作!" 
				@confirm="dialogConfirm"
				@close="dialogClose">
				</uni-popup-dialog>
			</uni-popup>
		</view>

		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderList:[],
				orderId:null,
				isVerified:false
			};
		},
		onLoad(options) {
			//console.log('传递过来的数据' + options.data);
			this.orderList = JSON.parse(decodeURIComponent(options.data));
			this.orderId = options.ordId;
			
			console.log(this.orderList);
			if (this.orderList[0].ordStatus == '已完成' || this.orderList[0].ordStatus == '已退款' || this.orderList[0].ordStatus ==
				'已取消') {
				this.isVerified = true;
			} else {
				this.isVerified = false;
			}
		},
		methods:{
			
			
			dialogToggle(type) {
				this.$refs.alertDialog.open()
			},
			dialogConfirm() {
				var that = this;
				console.log(" 订单号 " + this.orderId)
				uni.request({
					url: 'http://localhost:8080/carShopService/hexiao/updateOrderStatus?ordId=' + that.orderId,
					success: (res) => {
						if (res.statusCode === 200 && res.data === 1) {
							console.log('核销成功');
							this.isVerified=true;
						} else {
							console.log('核销失败：');
						}
					}
				})
				
				
			},
			
			
		}
	}
</script>

<style lang="scss">
	
	.info{
		background-color: white;
		height: 1100rpx;
		width: 95%;
		position: absolute;
		top: 150rpx;
		left: 20rpx;
		border-radius: 20rpx;
		z-index: 1
	}
	.btn{
		margin: 930rpx auto;
		width: 70%;
	}
	.one{
		margin: 50rpx 30rpx;
		border-bottom: 5px solid #F9F9F9;
		view{
			margin-bottom: 30rpx;
			.content{
				font-size: 13px;
			}
			.detail{
				font-size: 13px;
				float: right;
			}
		}
	}
	

</style>
